home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20000114-20000217 / 000135_news@columbia.edu _Mon Jan 24 18:27:33 2000.msg < prev    next >
Internet Message Format  |  2020-01-01  |  7KB

  1. Return-Path: <news@columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id SAA21897
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Mon, 24 Jan 2000 18:27:32 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id SAA20871
  7.     for kermit.misc@watsun.cc.columbia.edu; Mon, 24 Jan 2000 18:23:31 -0500 (EST)
  8. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  9. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  10. Subject: Case Study #15: File Selection
  11. Date: 24 Jan 2000 23:23:30 GMT
  12. Organization: Columbia University
  13. Message-ID: <86imti$kc4$1@newsmaster.cc.columbia.edu>
  14. To: kermit.misc@columbia.edu
  15.  
  16.  
  17. A question we see posted on the newsgroups at least once a week is "how
  18. do I delete files more than a week old?"  Of course each operating system
  19. might (or might not) have its own way of doing this; some straightforward
  20. (like VMS's DELETE /BEFORE command), some not so obvious:
  21.  
  22.   find <directoryname> -type f -mtime +7 -print | xargs rm
  23.  
  24. This is just one example of a larger class of problems: "how can I select
  25. files for a particular action?".
  26.  
  27. C-Kermit 7.0 handles file selection in two ways: first by incorporating
  28. the notion of "switches" into its command language, and second by its new,
  29. more-powerful wildcard syntax.  We might discuss wildcard syntax another
  30. time (it's about what you get in csh or bash) but you can find out all
  31. about it any time by typing "help wildcard" at the C-Kermit prompt.
  32.  
  33. Switches (command modifiers) should be familiar to anybody who has used
  34. the command languages of DOS, VMS, TOPS-10 or TOPS-20, RT-11, RSX-11,
  35. AOS/VS, and so on.  Switches are optional keywords that begin with a
  36. slash (/) and might also take an argument.  For example:
  37.  
  38.   delete /before:-1week *.log
  39.  
  40. Here "delete" is the command, "/before:" is the switch, "-1week" is the
  41. switch argument, and "*.log" is the target of the command.  This deletes
  42. all files whose names end with ".log" in the current directory that are
  43. more than a week old.
  44.  
  45. Let's see what other switches are offered by Kermit's DELETE command:
  46.  
  47.  C-Kermit>delete ? File specification;
  48.    or switch, one of the following:
  49.    /after:         /except:        /noask          /not-after:
  50.    /ask            /heading        /nodotfiles     /not-before:
  51.    /before:        /larger-than:   /noheading      /simulate
  52.    /dotfiles       /list           /nolist         /smaller-than:
  53.  C-Kermit>delete
  54.  
  55. The name of each switch should be suggestive of its function, but of
  56. course you can type "help delete" for a description of each switch.
  57.  
  58. The switches that are listed with a terminating colon (:) take arguments.
  59. You can find out what the argument is by typing a question mark after the
  60. colon:
  61.  
  62.  C-Kermit>delete /before:? File-time
  63.  C-Kermit>delete /except:? Pattern
  64.  
  65. The /BEFORE, /AFTER, and related switches accept dates and/or times, which
  66. can be given in almost any format that is not ambiguous, and you can also
  67. give relative dates like "yesterday", "-12days", and "+2weeks".
  68.  
  69. The /EXCEPT switch lets you enter an exception list: one or more filenames
  70. or patterns that should be excluded from the operation.
  71.  
  72. Here's an example:
  73.  
  74.   delete /dotfiles /before:-1week /larger:10000 /except:*keep* *.log
  75.  
  76. This deletes all files, including dotfiles (like ".readme"), whose names
  77. end with ".log" that are more than a week old and larger than 10000 bytes,
  78. except the ones whose names include the word "keep".
  79.  
  80. In case you're unsure of yourself, you can include the /SIMULATE switch,
  81. which tells C-Kermit to list the files it WOULD have deleted without
  82. actually deleting them.
  83.  
  84. Of course file-selection (and other) switches are not only for the DELETE
  85. command.  Most of C-Kermit's file transfer and management commands now have
  86. switches; for example, the SEND command:
  87.  
  88.  C-Kermit>send ? Filename, or switch, one of the following:
  89.    /after:         /except:        /nodotfiles     /recursive
  90.    /array:         /filter:        /not-after:     /rename-to:
  91.    /as-name:       /filenames:     /not-before:    /smaller-than:
  92.    /before:        /larger-than:   /pathnames:     /starting-at:
  93.    /binary         /listfile:      /print:         /subject:
  94.    /command        /mail:          /protocol:      /text
  95.    /delete         /move-to:       /quiet
  96.    /dotfiles       /nobackup       /recover
  97.  C-Kermit>send
  98.  
  99. Or the new PURGE command, for managing those annoying backup files:
  100.  
  101.  C-Kermit>purge ? Filename or switch, one of the following:
  102.    /after:         /heading        /nodotfiles     /not-before:
  103.    /ask            /keep:          /noheading      /page
  104.    /before:        /larger-than:   /nolist         /recursive
  105.    /dotfiles       /list           /nopage         /simulate
  106.    /except:        /noask          /not-after:     /smaller-than:
  107.  C-Kermit>purge
  108.  
  109. Or the new built-in DIRECTORY command:
  110.  
  111.  C-Kermit>dir ? File specification; or switch, one of the following:
  112.    /after:         /englishdate    /noheading      /recursive
  113.    /all            /except:        /nomessage      /reverse
  114.    /array:         /files          /nopage         /smaller-than:
  115.    /ascending      /heading        /norecursive    /sort:
  116.    /backup         /isodate        /nosort         /xfermode
  117.    /before:        /larger-than:   /not-after:     /verbose
  118.    /brief          /message:       /not-before:
  119.    /directories    /nobackup       /noxfermode
  120.    /dotfiles       /nodotfiles     /page
  121.  C-Kermit>dir
  122.  
  123. You can use switches in any desired combination to obtain results you
  124. couldn't get before.  Returning to our original example, let's say that
  125. rather than deleting files that are more than a week old, we want to move
  126. them to another computer.  Assuming the connection is already made and the
  127. other Kermit is in server (or receive) mode, the command is deceptively
  128. simple:
  129.  
  130.   send /delete /before:-1week *.*
  131.  
  132. But remember all that's going on behind the scenes:
  133.  
  134.  . Automatic per-file text/binary-mode switching
  135.  . File timestamp and permission preservation
  136.  . Atomic file movement
  137.  
  138. And so on; most of this has been covered in previous installments.
  139.  
  140. To read all about switches, see Section 1.5 of the ckermit2.txt file.
  141. Section 1.6 explains date/time formats.  The DIRECTORY command is
  142. described in Section 4.5.1 and the DELETE and PURGE commands in Section
  143. 4.5.4.  File-transfer command switches are documented in Section 4.7.
  144. The new wildcard syntax is covered in Section 4.9.
  145.  
  146. - Frank